using System;
using System.Collections.Generic;
using System.Text;
using Wrath.Xml;
using System.ComponentModel;
using Wrath.RuleForge.Interfaces;

namespace Wrath.RuleForge.Property
{
    public class FontWrapper : IPropertyWrapper<Element>
    {
        private bool hasChanged;
        private Element element;

        private Wrath.Xml.Attribute fgfFileName;
        private Wrath.Xml.Attribute colorValue;

        [Category("Font")]
        [Description("The filename of the font file.")]
        public string File
        {
            get
            {
                return fgfFileName.Value;
            }
            set
            {
                fgfFileName.Value = value;
            }
        }

        [Category("Font")]
        [Description("The RGB color of the font in the format #RRGGBB.")]
        public string Color
        {
            get
            {
                return colorValue.Value;
            }
            set
            {
                colorValue.Value = value;
            }
        }

        public FontWrapper(Element element)
        {
            this.element = element;

            Element fgfFileElement = element.FindFirstElement("fgffile", false);
            fgfFileName = fgfFileElement.FindAttribute("name");

            Element colorElement = element.FindFirstElement("color", false);
            colorValue = colorElement.FindAttribute("value");
        }

        #region IPropertyWrapper<Element> Members

        [Browsable(false)]
        public bool HasChanged
        {
            get
            {
                return hasChanged;
            }
            set
            {
                hasChanged = value;
            }
        }

        [Browsable(false)]
        public Element Data
        {
            get { return element; }
        }

        #endregion
    }
}
